import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
/**
 * ImageViewer is the main class of the image viewer application. It builds
 * and displays the application GUI and initialises all other components.
 * 
 * To start the application, create an object of this class.
 * 
 * @author Michael Kolling and David J Barnes 
 * @version 0.1
 */
public class GUI implements ActionListener
{
    private JFrame f;
    private JPanel p;
    private JButton b1;
    private JLabel lab;
    private JTextField t;
    public KantineSimulatie kantinesim;
    
    /**
     * Create an ImageViewer show it on screen.
     */
    public GUI()
    {
        makeFrame();
    }
    
    // ---- swing stuff to build the frame and all its components ----
    
    /**
     * Create the Swing frame and its content.
     */
    private void makeFrame()
    {
            f = new JFrame("KantineSimulatie");
            f.setVisible(true);
            f.setSize(600, 400);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            
            p = new JPanel();
            
            b1 = new JButton("Simuleer");
            lab = new JLabel ("Hoeveel dagen:");
            
            t = new JTextField();
            t.setSize(50, 50);
            
            t.addActionListener(this);
            
            
            p.add(lab);
            p.add(t);
            p.add(b1);
            
            f.add(p);
    }
    
    
    public void actionPerformed(ActionEvent event)
    {
        String command = event.getActionCommand();
        Integer getal = new Integer(command); // omzetten van String naar Integer
        int value = getal.intValue(); // omzetten van Integer naar int 
        //System.out.println(command);
        kantinesim.simuleer(value);
        
    }
}

